package com.vecspace.constant;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class AppConst {

    /**在request中存储当前登录的租户id的属性名称*/
    public static final String REQUEST_ATTR_NAME__APP_INSTANCE_ID = "app_instance_id";

    private static String appCode;

    public String getAppCode() {
        return AppConst.appCode;
    }
    @Value("${app.code}")
    public void setAppCode(String appCode) {
        AppConst.appCode = appCode;
    }
    
    public static String getAppKey() {
    	return appCode;
    }
    
	//---------------------------------------------------------------
	private static String sysRootMenuCode;	

	public String getSysRootMenuCode() {
		return sysRootMenuCode;
	}

	@Value("${app.rootFunCode}")
	public void setSysRootMenuCode(String sysRootMenuCode) {
		AppConst.sysRootMenuCode = sysRootMenuCode;
	}

	/**
	 * 获取系统的功能菜单根节点的FunCode，比如SYS-FPM-FUNS
	 * @return 
	 * @author wanghua
	 */
	public static String getSystemRootMenuCode(){
		return sysRootMenuCode;
	}

	//---------------------------------------------------------------
    
    private static boolean isDebugModel = false;//系统是否处理debug模式，可以在app.propertied文件中定义 app.debug=true


	/**系统是否处于debug状态*/
	public static boolean isDebug(){
		return isDebugModel;
	}

	/**系统是否处于正式运行状态*/
	@Value("${sys.debug}")
	public void setDebugModel(boolean isDebugModel) {
		AppConst.isDebugModel = isDebugModel;
	}

	/**设置系统是否处于debug状态
	 * @param isDebug
	 * @author: wanghua
	 */
	public static void setDebug(boolean isDebug) {
		AppConst.isDebugModel = isDebug;
	}
	
	//----------------------------------------------------------------

	private static String webCharset = "utf-8";
	/**系统采用的字符集
	 * 在 app文件中定义 web.charset=utf-8
	 * @return
	 * @author: wanghua
	 */
	public static String getCharset(){
		return webCharset;
	}

	public String getWebCharset(){
		return webCharset;
	}

	@Value("${web.charset:utf-8}")
	public void setWebCharset(String value){
		AppConst.webCharset = value;
	}
}
